package javaCode.chapter05;

//ArrayAssign 数组分配

public class ArrayAssign {

    public static void main(String[] args) {

        //基本数据类型赋值，赋值方式为值拷贝
        int n1 = 10;
        int n2 = n1;

        n2 = 80;
        System.out.println("n1=" + n1);
        System.out.println("n2=" + n2);

        //数组在默认情况下是引用传递，赋的值是地址，赋值方式为 引用赋值/地址赋值
        //是一个地址，arr2编号会影响到 arr1
        int[] arr1 = {1, 2, 3};
        int[] arr2 = arr1; // 把 arr1赋给 arr2
        arr2[0] = 10;

        //看看arr1的值
        System.out.println("===数组arr1===");
        for(int i=0;i<arr1.length;i++){
            System.out.print(arr1[i]+" ");
        }
        System.out.println();


    }
}


